package com.java.netty.common.helper;


import com.java.netty.common.enums.ProtocolVer;
import com.java.netty.common.pptp.Pptp;

public class PPTPHelper {

    public static byte[] buildMsg(Pptp mPptp) {
        int dataLen = mPptp.getData().length();
        int time = mPptp.getHead().getTime();
        byte[] result = new byte[6 + dataLen];
        //固定消息头
        result[0] = (byte) (mPptp.getHead().getType() << 2);
        result[1] = (byte) (ProtocolVer.PPTP_V3.getVersion().byteValue());
        result[2] = (byte) ((time >> 8) & 0xff);// 高位
        result[3] = (byte) (time & 0xff);// 低位
        result[4] = (byte) ((dataLen >> 8) & 0xff);// 高位
        result[5] = (byte) (dataLen & 0xff);// 低位
        System.arraycopy(mPptp.getData().getBytes(), 0, result, 6, dataLen);
        return result;
    }
}